package com.chengdu.third.dao;

import com.chengdu.third.pojo.Laws;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ILawsDao {

    /**
     * 查找所有
     * @return
     */
    @Select("select * from laws")
    public List<Laws> find();

    /**
     * 根据id删除
     * @param id
     */
    @Delete("delete from laws where id  = #{id}")
    public void delete(long id);

    /**
     * 根据id修改
     * @param laws
     */
    @Update("update laws set type_id = #{type_id},content = #{content},update_time = #{update_time},Issue_unit = #{Issue_unit} where id = #{id}")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    public void update(Laws laws);

    /**
     * 增加
     * @param laws
     */
    @Insert("insert into  laws(`type_id`,`content`,`create_time`,`update_time`,`text_number`,`Issue_unit`) values(#{type_id},#{content},#{create_time},#{update_time},#{text_number},#{Issue_unit})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    public void add(Laws laws);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from laws where id = #{id}")
    public Laws getLawsById(long id);


    @Select ("select * from laws where type_id=2")
    public List<Laws> selectshixian();

    @Select ("select * from laws where type_id=1")
    public List<Laws> selectxiangzheng();

    @Select ("select * from laws where type_id=0")
    public List<Laws> selectcun();

}
